package com.liu.vueblog.controller;


import com.liu.vueblog.common.lang.Result;
import com.liu.vueblog.entity.User;
import com.liu.vueblog.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LiuXin
 * @since 2021-06-17
 */
@RestController
@RequestMapping("/vueblog/user")
public class UserController {
    @Resource
    public UserService userService;

    @RequiresAuthentication
    @RequestMapping(path = "/test",method = RequestMethod.GET)
    public User test(){
        return userService.getById(1L);
    }

    @RequestMapping(path = "/save", method = RequestMethod.POST)
    public Result save(@Validated @RequestBody User user){
        return Result.success(user);
    }
}
